home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / ptrp10.zip / PASTERP.DOC < prev    next >
Text File  |  1994-05-17  |  75KB  |  2,049 lines

  1.                                   - TOC-   1 -
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  PASTERP Language  ....................................................      1
  8.  OVERVIEW .............................................................      1
  9.  STATEMENTS ...........................................................      1
  10.  GLOBAL Statement .....................................................      2
  11.  LOCAL Statement ......................................................      2
  12.  WRITE Statement ......................................................      3
  13.  Assignment Statement .................................................      4
  14.  IF Statement .........................................................      4
  15.  WRITELN Statement ....................................................      4
  16.  FOR Statement ........................................................      5
  17.  WHILE Statement ......................................................      5
  18.  REPEAT Statement .....................................................      6
  19.  READLN Statement .....................................................      7
  20.  READ Statement .......................................................      7
  21.  Procedure Call Statement .............................................      8
  22.  RETURN Statement .....................................................      8
  23.  Procedure/Function Definition Statement ..............................      9
  24.  CONTINUE Statement ...................................................     10
  25.  VARIABLES ............................................................     10
  26.  EXPRESSIONS ..........................................................     11
  27.  Numeric Expressions ..................................................     11
  28.  Logical (Boolean) Expressions ........................................     12
  29.  String Expressions ...................................................     12
  30.  PASTERP Library ......................................................     13
  31.  PASTERP Standard Library .............................................     13
  32.  Standard Library Function : PI .......................................     14
  33.  Standard Library Function : SIN ......................................     14
  34.  Standard Library Function : EXP ......................................     14
  35.  Standard Library Function : ABS ......................................     15
  36.  Standard Library Function : COS ......................................     15
  37.  Standard Library Function : LN .......................................     15
  38.  Standard Library Function : LOG10 ....................................     15
  39.  Standard Library Function : LOG2 .....................................     15
  40.  Standard Library Function : RANDOM ...................................     15
  41.  Standard Library Function : ARCSIN ...................................     16
  42.  Standard Library Function : ARCTAN ...................................     16
  43.  Standard Library Function : COTAN ....................................     16
  44.  Standard Library Function : SQR ......................................     16
  45.  Standard Library Function : SQRT .....................................     16
  46.  Standard Library Function : TAN ......................................     16
  47.  Standard Library Function : ARCCOS ...................................     17
  48.  Standard Library Function : CHR ......................................     17
  49.  Standard Library Function : COPY .....................................     17
  50.  Standard Library Function : ORD ......................................     17
  51.  Standard Library Function : ROUND ....................................     17
  52.  Standard Library Function : TRUNC ....................................     17
  53.  Standard Library Function : DELETE ...................................     18
  54.  Standard Library Function : INSERT ...................................     18
  55.  Standard Library Function : LENGTH ...................................     18
  56.  Standard Library Function : POS ......................................     18
  57.  Standard Library Function : STR ......................................     18
  58.  Standard Library Function : VAL ......................................     18
  59.  Standard Library Function : APPEND ...................................     19
  60.  Standard Library Function : ASSIGN ...................................     19
  61.  
  62.  
  63.  
  64.                                   - TOC-   1 -
  65.                                   - TOC-   2 -
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  Standard Library Function : CLOSE ....................................     19
  72.  Standard Library Function : RESET ....................................     19
  73.  PASTERP Extended Library .............................................     20
  74.  Standard Library Function : DEC ......................................     20
  75.  Standard Library Function : EOF ......................................     20
  76.  Standard Library Function : INC ......................................     20
  77.  Standard Library Function : REWRITE ..................................     20
  78.  Overview of PASTERP <-> PASCAL interface .............................     21
  79.  PASTERP Interface to host language ...................................     21
  80.  Initializing a PASTERP instance ......................................     22
  81.  Registering Procedures and Functions .................................     22
  82.  Extending the PASTERP syntax/system library ..........................     24
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.                                   - TOC-   2 -
  129.                                     -    1 -
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. ******************************************************************************
  137. *                                  OVERVIEW                                  *
  138. ******************************************************************************
  139.  
  140. PASTERP is a PASCAL-like interpreter, with an embedding interface to
  141. Borland PASCAL programs. Now you can enhance your applications by providing
  142. an easy to use and powerful extension language to your projects.
  143.  
  144. The language parsed by the interpreter is a subset of PASCAL, with 
  145. syntax enhancements that make it easier to read. In most of the constructs
  146. the PASTERP language is also more forgiving than PASCAL.
  147.  
  148. This document describes the language syntax, the supported run-time 
  149. library, and the interface provided to embed the language in your
  150. application projects.
  151.  
  152. Related Topics :
  153.  PASTERP Language
  154.  PASTERP Run-Time Library
  155.  PASTERP <-> Borland PASCAL Interface
  156.  
  157.  
  158. ******************************************************************************
  159. *                             PASTERP Language                               *
  160. ******************************************************************************
  161.  
  162. The PASTERP Language is based on PASCAL with some enhancements that simplify
  163. parsing (both for the machine and the users), and is more forgiving than
  164. PASCAL.
  165.  
  166. The language support is described in the following sections :
  167.  
  168.  Statements
  169.  Varaibles
  170.  Expressions
  171.  
  172. To understand the language capabilities please refer to the Run-Time Library
  173. as well.
  174.  
  175.  
  176. ******************************************************************************
  177. *                                 STATEMENTS                                 *
  178. ******************************************************************************
  179.  
  180. The following statements are recognized in the PASTERP Language :
  181.  
  182.  Assignment Statement
  183.  CONTINUE Statement
  184.  FOR Statement
  185.  GLOBAL Statement
  186.  IF Statement
  187.  LOCAL Statement
  188.  Procedure Call Statement
  189.  
  190.  
  191.  
  192.                   pasterp, Page #   1   Date 17-5-1994 Tuesday
  193.                                     -    2 -
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  Procedure/Function Definition Statement
  200.  READLN Statement
  201.  READ Statement
  202.  REPEAT Statement
  203.  RETURN Statement
  204.  WHILE Statement
  205.  WRITELN Statement
  206.  WRITE Statement
  207.  
  208.  
  209. ******************************************************************************
  210. *                              GLOBAL Statement                              *
  211. ******************************************************************************
  212.  
  213. The GLOBAL statement is used to define a global variable, that can be accessed
  214. from all the procedures of the PASTERP program being executed. It is important
  215. to call the GLOBAL statement only ONCE, or the interpreter will not be able to 
  216. recognize it as a valid variable definition.
  217.  
  218. It is a good idea to call this statement in an initialization routine that 
  219. can be modified by your users.
  220.  
  221. The GLOBAL statement syntax is as follows :
  222.  
  223. GLOBAL Var-Name : Var-Type [= Initialization-Value] [;]
  224.        [Var-Name ... ]
  225. ENDVAR
  226.  
  227. Where Var-Name is the name of the variable, Var-Type is the type of the 
  228. variable, and optionally, an Initialization-Value can be specified, using an
  229. expression.
  230.  
  231. Multiple Var-Names can be specified, each one of them will be allowed only if
  232. there is no previous variable defined with the same name.
  233.  
  234. Please note that since PASTERP is an interpreted language, the optional 
  235. Initialization-Value can be an expression that references functions, variables
  236. etc.., however, if you want to translate your PASTERP sources to PASCAL, you 
  237. should restrict yourself to constant Initialization-Values only.
  238.  
  239. Related Topics :
  240.  LOCAL Statement
  241.  Expressions
  242.  Variables
  243.  
  244.  
  245. ******************************************************************************
  246. *                              LOCAL Statement                               *
  247. ******************************************************************************
  248.  
  249. The LOCAL statement is used to define a Local variable to the currently 
  250. executing procedure, that variable can NOT be accessed from any other procedure 
  251. of the PASTERP program being executed. It is important to call the LOCAL 
  252. statement only ONCE in the procedure, or the interpreter will not be able to 
  253.  
  254.  
  255.  
  256.                   pasterp, Page #   2   Date 17-5-1994 Tuesday
  257.                                     -    3 -
  258.  
  259.  
  260.  
  261.  
  262.  
  263. recognize it as a valid variable definition.
  264.  
  265. It is a good idea to call this statement in an initialization part of your
  266. routine, and use it later. The LOCAL statement is closer to the C/C++ 
  267. variable definition that is performed in the code (and not out of it as in 
  268. PASCAL), however, unlike C/C++, the variable is not local to a block,
  269. but to the entire procedure, from the point of it's declaration.
  270.  
  271. The LOCAL statement syntax is as follows :
  272.  
  273. LOCAL|VAR Var-Name : Var-Type [= Initialization-Value] [;]
  274.        [Var-Name ... ]
  275. ENDVAR
  276.  
  277. For easier translations from PASCAL to PASTERP, the keyword VAR can be used 
  278. instead of LOCAL.
  279.  
  280. Where Var-Name is the name of the variable, Var-Type is the type of the 
  281. variable, and optionally, an Initialization-Value can be specified, using an
  282. expression.
  283.  
  284. Multiple Var-Names can be specified, each one of them will be allowed only if
  285. there is no previous variable defined with the same name.
  286.  
  287. Please note that since PASTERP is an interpreted language, the optional 
  288. Initialization-Value can be an expression that references functions, variables
  289. etc.., however, if you want to translate your PASTERP sources to PASCAL, you 
  290. should restrict yourself to constant Initialization-Values only.
  291.  
  292. Related Topics :
  293.  GLOBAL Statement
  294.  Expressions
  295.  Variables
  296.  
  297.  
  298. ******************************************************************************
  299. *                              WRITE Statement                               *
  300. ******************************************************************************
  301.  
  302. The WRITE statement is used to write a list of expressions. This statement is
  303. very close to the PASCAL Write procedure.
  304.  
  305. The WRITE statement syntax is :
  306.  
  307. WRITE([File, ]Expr-1 [[,] Expr-2 [[,] Expr-3]])[;]
  308.  
  309. Where Expr-1, Expr-2 .. are expressions that produce an output. In this version
  310. of PASTERP these are Numeric and String Expressions.
  311.  
  312. The optional File parameter is the name of the file that the output will be
  313. directed to. In this version of PASTERP, only TEXT files are supported.
  314.  
  315. Related Topics :
  316.  WRITELN Statement
  317.  
  318.  
  319.  
  320.                   pasterp, Page #   3   Date 17-5-1994 Tuesday
  321.                                     -    4 -
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  Expressions
  328.  
  329.  
  330. ******************************************************************************
  331. *                             WRITELN Statement                              *
  332. ******************************************************************************
  333.  
  334. The WRITELN statement is used to write a list of expressions. This statement is
  335. very close to the PASCAL Writeln procedure. This statement will write a newline
  336. character at the end of the arguments list.
  337.  
  338. The WRITELN statement syntax is :
  339.  
  340. WRITELN([File, ]Expr-1 [[,] Expr-2 [[,] Expr-3]])[;]
  341.  
  342. or 
  343.  
  344. WRITELN[;]
  345.  
  346. Where Expr-1, Expr-2 .. are expressions that produce an output. In this version
  347. of PASTERP these are Numeric and String expressions.
  348.  
  349. The optional File parameter is the name of the file that the output will be
  350. directed to. In this version of PASTERP, only TEXT files are supported.
  351.  
  352. Related Topics :
  353.  WRITE Statement
  354.  Expressions
  355.  
  356.  
  357. ******************************************************************************
  358. *                            Assignment Statement                            *
  359. ******************************************************************************
  360.  
  361. The ASSIGNMENT statement assigns a value to a variable. The variable to 
  362. be assigned is called the LVALUE of the assignment, and the expression that
  363. is being evaluated is called the RVALUE of the assignment.
  364.  
  365. The ASSIGNMENT statement Syntax is as follows :
  366.  
  367. Variable := Expression
  368.  
  369. Where Variable is a variable defined before, as a GLOBAL or LOCAL variable, or
  370. was defined by the application program that set the Variable.
  371.  
  372. The Expression is a Numeric/String/Logical expression that is legal for the
  373. LVALUE variable it will be assigned to.
  374.  
  375. Related Topics :
  376.  Expressions
  377.  Varaibles
  378.  PASTERP <-> Borland PASCAL Interface
  379.  
  380.  
  381.  
  382.  
  383.  
  384.                   pasterp, Page #   4   Date 17-5-1994 Tuesday
  385.                                     -    5 -
  386.  
  387.  
  388.  
  389.  
  390.  
  391. ******************************************************************************
  392. *                                IF Statement                                *
  393. ******************************************************************************
  394.  
  395. The IF statement is used to choose code execution according to a set of rules
  396. that is correct (evaluated to TRUE) when the IF statement is executed. This 
  397. statement is semantically equal to the PASCAL IF statement.
  398.  
  399. The IF statement syntax is :
  400.  
  401. IF (Conditional-Expression) [THEN]
  402.         ... commands to do if conditional-expression is evaluated to TRUE
  403. [ELSE
  404.         ... commands to do if conditional-expression is evaluated to FALSE]
  405. ENDIF
  406.  
  407. Where Conditional-Expression is a logical expression that can be evaluated to
  408. a Boolean value.
  409.  
  410. Unlike in PASCAL, every IF statement must end with the ENDIF keyword. An 
  411. optional ELSE keyword defines the end of the statement block that should be evaluated
  412. when the Conditional-Expression is evaluated to TRUE, and the start of the 
  413. statement block that should be executed if the Conditional-Expression is
  414. evaluated to FALSE.
  415.  
  416. Related Topics :
  417.  Expressions
  418.  
  419.  
  420. ******************************************************************************
  421. *                              WHILE Statement                               *
  422. ******************************************************************************
  423.  
  424. The WHILE statement is used to create loops that are executed during the
  425. time a specific condition is true. The condition is re-evaluated at the 
  426. beginning of the loop, and if the logic evaluation returns TRUE, a block of
  427. commands is executed, until a ENDWHILE (or WEND) keyword is reached.
  428.  
  429. The WHILE statement syntax is :
  430.  
  431. WHILE (Conditional-Expression)
  432.         ... block of statements
  433. ENDWHILE
  434.  
  435. Where Conditional-Expression is a logical expression that can be evaluated to
  436. a Boolean value.
  437.  
  438. Related Topics :
  439.  Expressions
  440.  REPEAT Statement
  441.  FOR Statement
  442.  
  443.  
  444. ******************************************************************************
  445.  
  446.  
  447.  
  448.                   pasterp, Page #   5   Date 17-5-1994 Tuesday
  449.                                     -    6 -
  450.  
  451.  
  452.  
  453.  
  454.  
  455. *                               FOR Statement                                *
  456. ******************************************************************************
  457.  
  458. The FOR statement is used to loop through a block of instructions a fixed
  459. number of times.
  460.  
  461. The Start/End and Step conditions of the loop are evaluated only once, 
  462. when the FOR statement starts, this is different from the WHILE and REPEAT
  463. statement that are re-evaluated with each iteration.
  464.  
  465. This statement is close to the standard PASCAL FOR statement. 
  466. It adds a STEP parameter that defines how the loop's control variable is 
  467. incremented/decremented. Notice that PASTERP Pascal can use REAL (Floating
  468. Point) Variables as control variables.
  469.  
  470. The FOR statement syntax is :
  471.  
  472. FOR Control-Variable := Start-Value TO|DOWNTO End-Value [STEP Step-Value]
  473.         ... Block of statement
  474. ENDFOR
  475.  
  476. Where Control-Variable is the Numeric variable that will be used as a control variable
  477. for the loop, Start-Value is the initial value assigned to the control 
  478. variable, End-Value is the value that the Control-Variable will be tested
  479. against. If the optional Step-Value is supplied, this is the value that will
  480. be added to the Control-Variable.
  481.  
  482. The TO and DOWNTO keywords are used for the same purpose, if the STEP parameter
  483. is specified, the Step-Value sets the value that will be added to the 
  484. Control-variable. If the STEP parameter is not supplied, using TO will assign
  485. 1.0 to the Step-Value, and DOWNTO will assign -1.0 to this value.
  486.  
  487. Related Topics :
  488.  Expressions
  489.  REPEAT Statement
  490.  WHILE Statement
  491.  
  492.  
  493. ******************************************************************************
  494. *                              REPEAT Statement                              *
  495. ******************************************************************************
  496.  
  497. The REPEAT statement is used to create loops that are executed during the
  498. time a specific condition is false. The condition is re-evaluated at the 
  499. end of the loop, and if the logic evaluation returns FALSE, a block of
  500. commands is executed.
  501.  
  502. This statement is different from the WHILE statement, because the command
  503. block will be performed at least once, until the first time the 
  504. conditional-expression is evaluated. In the WHILE statement, the command block
  505. might not be executed even once.
  506.  
  507. The REPEAT statement syntax is :
  508.  
  509.  
  510.  
  511.  
  512.                   pasterp, Page #   6   Date 17-5-1994 Tuesday
  513.                                     -    7 -
  514.  
  515.  
  516.  
  517.  
  518.  
  519. REPEAT
  520.         ... block of statements
  521. UNTIL (Conditional-Expression)
  522.  
  523. Where Conditional-Expression is a logical expression that is re-evaluated at 
  524. the end of the loop, and the loop is executed while it is  evaluated to FALSE.
  525.  
  526. Related Topics :
  527.  Expressions
  528.  WHILE Statement
  529.  FOR Statement
  530.  
  531.  
  532. ******************************************************************************
  533. *                               READ Statement                               *
  534. ******************************************************************************
  535.  
  536. The READ statement is used to get input from the keyboard, or a file. Unlike
  537. the PASCAL READ statement, PASTERP READ statement receives only one argument
  538. to read.
  539.  
  540. The READ statement syntax is :
  541.  
  542. READ([File, ] Variable)[;]
  543.  
  544. Where Variable is the variable the data will be read into. The optional File
  545. parameters is the source file of the input, if no file is specified, the input
  546. is received from the keyboard, otherwise, it arrives from the specified file.
  547. In this version of PASTERP the only files supported are TEXT files.
  548.  
  549. Related Topics :
  550.  
  551.  Variables
  552.  READLN Statement
  553.  
  554.  
  555. ******************************************************************************
  556. *                              READLN Statement                              *
  557. ******************************************************************************
  558.  
  559. The READLN statement is used to get input from the keyboard, or a file. Unlike
  560. the PASCAL READLN statement, PASTERP READLN statement receives only one argument
  561. to read.
  562.  
  563. The READLN statement syntax is :
  564.  
  565. READLN([File, ] Variable)[;]
  566.  
  567. Where Varaible is the varaible the data will be read into. The optional File
  568. parameters is the source file of the input, if no file is specified, the input
  569. is received from the keyboard, otherwise, it arrives from the specified file.
  570. In this version of PASTERP the only files supported are TEXT files.
  571.  
  572. Related Topics :
  573.  
  574.  
  575.  
  576.                   pasterp, Page #   7   Date 17-5-1994 Tuesday
  577.                                     -    8 -
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  Variables
  585.  READ Statement
  586.  
  587.  
  588. ******************************************************************************
  589. *                          Procedure Call Statement                          *
  590. ******************************************************************************
  591.  
  592. PROCEDURE (and FUNCTIONS) CALL are recognized as statements by the PASTERP
  593. language. When a procedure call is recognized, the PASTERP interpreter passes
  594. control to the specified procedure/function, and continues execution in that
  595. function/procedure. When the called procedure exits, execution is resumed after
  596. the call to the procedure/function.
  597.  
  598. The PROCEDURE/FUNCTION CALL syntax is :
  599.  
  600. Procedure-Name[(Parameter-1, Parameter-2)]
  601.  
  602. Where Procedure-Name is the name of the procedure/function, that had been
  603. defined either by the calling application, or in the PASTERP code.
  604.  
  605. The optional Parameters are the parameters defined in the procedure definition.
  606.  
  607. Related Topics :
  608.  Procedure/Function Definition
  609.  
  610.  
  611. ******************************************************************************
  612. *                              RETURN Statement                              *
  613. ******************************************************************************
  614.  
  615. The RETURN statement is used to exit a procedure/function, and according to the
  616. function/procedure return type, return a value.
  617.  
  618. The RETURN statement is close to the C/C++ statement, that has no equivalent
  619. in PASCAL.
  620.  
  621. An alternative to the RETURN statement is to set the function value, by
  622. assignment, end exit when the ENDPROC keyword is reached, this method is
  623. equivalent to the PASCAL return model.
  624.  
  625. The RETURN statement syntax is :
  626.  
  627. RETURN [Expression] [;]
  628.  
  629. Where Expression is the expression that defines the value the function will 
  630. return, if the function/procedure does not return a value (return type = void),
  631. the expression is not necessary.
  632.  
  633. An alternate syntax is :
  634.  
  635. FUNCTION myfunc(Parameter-List) : Return-Type
  636.  [... some code]
  637.  
  638.  
  639.  
  640.                   pasterp, Page #   8   Date 17-5-1994 Tuesday
  641.                                     -    9 -
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  myfunc := expression
  648.  [... some code]
  649. ENDPROC
  650.  
  651. Related Topics :
  652.  Expressions
  653.  Procedure/Function definition
  654.  
  655.  
  656. ******************************************************************************
  657. *                  Procedure/Function Definition Statement                   *
  658. ******************************************************************************
  659.  
  660. There are four (4) types of procedures/functions that PASTERP recognizes, of 
  661. these two are implemented/registered by the Host Application, one is 
  662. implemented by PASTERP code, and one will be implemented in a future version 
  663. of PASTERP by dynamic binding.
  664.  
  665. This section describes procedures and functions definition that are defined
  666. in PASTERP source. The other types are defined elsewhere in this document.
  667.  
  668. Procedures or functions that are defined in PASTERP source must be defined
  669. on a new source line. You can not start a procedure/function definition on a 
  670. line that has any previous statement, or even remarks.
  671.  
  672. The following syntax is used to define procedures and functions :
  673.  
  674. PROCEDURE Proc-Name[(Parameters-List)] [BEGIN]
  675.  .. procedure code
  676. ENDPROC
  677.  
  678. or 
  679.  
  680. FUNCTION Func-Name[(Parameter-List)] : Return-Type [BEGIN]
  681.  .. function code
  682. ENDPROC
  683.  
  684. Where Proc-Name/Func-Name is the name of the procedure. Please note that this
  685. name must be unique, or a problem might occur.
  686.  
  687. The optional Parameter-List is a list of parameters that should be passed 
  688. to the procedure/function, using the following syntax :
  689.  
  690. Parameter-Name : Parameter-Type [, Parameter-Name : Parameter-Type [..]]
  691.  
  692. Where Parameter-Name is the name the parameter will be called in the 
  693. procedure, and Parameter-Type is the type of the parameter. 
  694.  
  695. Return-Type in a FUNCTION definition is the type of the result returned by
  696. the function.
  697.  
  698. Please note that unlike in PASCAL, procedures and functions that are recognized
  699. in expressions/statements even if they are declared and defined after the
  700. procedure/function call. This can be done, because the interpreter updates
  701.  
  702.  
  703.  
  704.                   pasterp, Page #   9   Date 17-5-1994 Tuesday
  705.                                     -   10 -
  706.  
  707.  
  708.  
  709.  
  710.  
  711. the internal procedure table while it loads the source file to be interpreted.
  712.  
  713. Another important issue to notice, is that PASTERP procedures/functions CANNOT be nested in other procedures/functions. This is more like the C/C++ functions scope rules.
  714.  
  715. Related Topics :
  716.  RETURN Statement
  717.  
  718.  
  719. ******************************************************************************
  720. *                             CONTINUE Statement                             *
  721. ******************************************************************************
  722.  
  723. The CONTINUE statement is used to start a new iteration of a WHILE, REPEAT or
  724. FOR statement. The CONTINUE statement is evaluated as a ENDWHILE, UNTIL or
  725. ENDFOR keyword is for the relevant statements.
  726.  
  727. If no loop is defined, CONTINUE will result in an error code.
  728.  
  729. The CONTINUE syntax is :
  730.  
  731. CONTINUE
  732.  
  733. Related Topics :
  734.  WHILE Statement
  735.  FOR Statement
  736.  REPEAT Statement
  737.  
  738.  
  739. ******************************************************************************
  740. *                                 VARIABLES                                  *
  741. ******************************************************************************
  742.  
  743. PASTERP variables must be declared before they can be used. Variables can
  744. be declared either in the PASTERP source code, or in the host application.
  745.  
  746. PASTERP variables are either GLOBAL, where every procedure can access them
  747. (they have a global scope), or LOCAL to the procedure that executes them.
  748.  
  749. GLOBAL variables can be defined either from the PASTERP source, or the 
  750. host application code, LOCAL variables can be defined only in the PASTERP
  751. source code, or as parameters to procedures that can be defined by the
  752. host application that registers the procedure/function.
  753.  
  754. This version of PASTERP supports only the built-in variables types. New types can 
  755. not be created. Arrays and pointers are not supported in this version of PASTERP.
  756.  
  757. The supported variable types are :
  758.  
  759. BYTE            - Equal to PASCAL BYTE, a 0-255 integer type.
  760. INTEGER         - Equal to PASCAL INTEGER, a -32K .. + 32K integer type.
  761. WORD            - Equal to PASCAL WORD, a 0 .. 64K integer type.
  762. LONGINT         - Equal to PASCAL LONGINT, a -2 Billion .. + 2 Billion 
  763.                                            integer type.
  764. REAL            - Equal to PASCAL REAL, a 2.9*10-39 .. 1.7*10.38 float.
  765.  
  766.  
  767.  
  768.                   pasterp, Page #  10   Date 17-5-1994 Tuesday
  769.                                     -   11 -
  770.  
  771.  
  772.  
  773.  
  774.  
  775. STRING          - Equal to PASCAL STRING, a 255 Character dtring.
  776. PCHAR           - Equal to PASCAL PCHAR, an AsciiZ pointer.
  777. BOOLEAN         - Equal to PASCAL BOOLEAN, a TRUE/FALSE logical variable.
  778. TEXT            - EQUAL to PASCAL TEXT, a text mode file.
  779.  
  780. Please note that while PASTERP does not support most of the other PASCAL types,
  781. the keywords for all the standard PASCAL types are reserved by PASTERP for
  782. a future release that might support them.
  783.  
  784.  
  785. ******************************************************************************
  786. *                                EXPRESSIONS                                 *
  787. ******************************************************************************
  788.  
  789. PASTERP supports expressions that are either Numeric, String or Logical 
  790. expressions. These expressions are evaluated by the interpreter according
  791. to the type of function return, parameter or variable assignment.
  792.  
  793. In PASTERP all Numeric expressions are evaluated as REAL expressions, and
  794. data is converted back and forth if needed between REALs and the Variable/
  795. Parameter used.
  796.  
  797. All PASTERP String expressions are evaluated as AsciiZ expressions, and
  798. data is converted back and forth if needed between AsciiZ and STRING 
  799. variables/parameters.
  800.  
  801. The Expressions Definitions are :
  802.  
  803.  Numeric Expressions
  804.  String Expressions
  805.  Logical (Boolean) Expressions
  806.  
  807.  
  808. ******************************************************************************
  809. *                            Numeric Expressions                             *
  810. ******************************************************************************
  811.  
  812. In PASTERP all Numeric expressions are evaluated as REAL expressions, and
  813. data is converted back and forth if needed between REALs and the Variable/
  814. Parameter used.
  815.  
  816. The PASTERP Numeric Expressions will be described in a simple structure :
  817.  
  818. A Numeric Expression supports the standard math operations (+, -, *, /, %)
  819. it also supports the POWER operator, parenthesis, and unary minus.
  820.  
  821. The Primitive elements of a numeric expression are numeric constants, 
  822. variables of a numeric type, and functions that return a numeric value.
  823.  
  824. The operators in decreasing evaluation order are :
  825.  
  826.  Primitives
  827.  Parenthesis
  828.  Unary Minus
  829.  
  830.  
  831.  
  832.                   pasterp, Page #  11   Date 17-5-1994 Tuesday
  833.                                     -   12 -
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  POWER
  840.  Mul (*), Div (/), Mod (%)
  841.  Add (+), Sub (-)
  842.  
  843. Operators on the same line are left associative.
  844.  
  845. Related Topics :
  846.  
  847.  Variables
  848.  String Expressions
  849.  Logical (Boolean) Expressions
  850.  
  851.  
  852. ******************************************************************************
  853. *                             String Expressions                             *
  854. ******************************************************************************
  855.  
  856. All PASTERP String expressions are evaluated as AsciiZ expressions, and
  857. data is converted back and forth if needed between AsciiZ and STRING 
  858. variables/parameters.
  859.  
  860. String expressions support string concatenation using the + operator.
  861.  
  862. The Primitive elements of a string expression are string constants, 
  863. variables of a string type, and functions that return a string value.
  864.  
  865. Please note that you can concatenate AsciiZ (PCHAR) and STRING type strings.
  866.  
  867. String Constants are delimited either by single or double quotes, the
  868. matching quote is determined by the first quote, this way it is easy
  869. to create strings that include the "other" quote character. Like PASCAL,
  870. PASTERP Strings can also include the quote character by doubling it.
  871.  
  872. e.g. - "This string has a single quote right here : ' "
  873.  
  874. e.g. - 'And this one has a double quote here : " '
  875.  
  876. Related Topics :
  877.  
  878.  Variables
  879.  Numeric Expressions
  880.  Logical (Boolean) Expressions
  881.  
  882.  
  883. ******************************************************************************
  884. *                       Logical (Boolean) Expressions                        *
  885. ******************************************************************************
  886.  
  887. PASTERP logical expressions return a Boolean value - TRUE or FALSE.
  888.  
  889. The supported logical operators are AND, OR, XOR, NOT and parenthesis.
  890.  
  891. The Primitive Boolean values are TRUE, FALSE, variables of a Boolean type,
  892. and functions that return a Boolean type.
  893.  
  894.  
  895.  
  896.                   pasterp, Page #  12   Date 17-5-1994 Tuesday
  897.                                     -   13 -
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904. The operators in decreasing evaluation order are :
  905.  
  906.  Primitives
  907.  Parenthesis
  908.  NOT
  909.  AND
  910.  XOR
  911.  OR
  912.  
  913. Related Topics :
  914.  
  915.  Variables
  916.  Numeric Expressions
  917.  String Expressions
  918.  
  919.  
  920. ******************************************************************************
  921. *                              PASTERP Library                               *
  922. ******************************************************************************
  923.  
  924. The PASTERP Standard Library is based on the Standard PASCAL library, with
  925. some modifications needed to support the extended PASTERP features, and some
  926. procedures/functions missing because PASTERP does not support all the PASCAL
  927. features.
  928.  
  929. Extended library will be supplied in a future version, and will support 
  930. functions that are more related to the PC environment.
  931.  
  932. The library support is described in the following sections :
  933.  
  934.  Standard Library
  935.  Extended Library
  936.  
  937.  
  938. ******************************************************************************
  939. *                          PASTERP Standard Library                          *
  940. ******************************************************************************
  941.  
  942. The PASTERP Standard Library is based on the Standard PASCAL library, with
  943. some modifications needed to support the extended PASTERP features, and some
  944. procedures/functions missing because PASTERP does not support all the PASCAL
  945. features.
  946.  
  947. The following functions and procedures are defined in the standard library :
  948.  
  949.  Standard Library Function : ABS
  950.  Standard Library Function : APPEND
  951.  Standard Library Function : ARCCOS
  952.  Standard Library Function : ARCSIN
  953.  Standard Library Function : ARCTAN
  954.  Standard Library Function : ASSIGN
  955.  Standard Library Function : CHR
  956.  Standard Library Function : CLOSE
  957.  
  958.  
  959.  
  960.                   pasterp, Page #  13   Date 17-5-1994 Tuesday
  961.                                     -   14 -
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  Standard Library Function : COPY
  968.  Standard Library Function : COS
  969.  Standard Library Function : COTAN
  970.  Standard Library Function : DEC
  971.  Standard Library Function : DELETE
  972.  Standard Library Function : EOF
  973.  Standard Library Function : INC
  974.  Standard Library Function : INSERT
  975.  Standard Library Function : LENGTH
  976.  Standard Library Function : LN
  977.  Standard Library Function : LOG10
  978.  Standard Library Function : LOG2
  979.  Standard Library Function : ORD
  980.  Standard Library Function : PI
  981.  Standard Library Function : POS
  982.  Standard Library Function : RANDOM
  983.  Standard Library Function : RESET
  984.  Standard Library Function : REWRITE
  985.  Standard Library Function : ROUND
  986.  Standard Library Function : SIN
  987.  Standard Library Function : SQR
  988.  Standard Library Function : SQRT
  989.  Standard Library Function : STR
  990.  Standard Library Function : TAN
  991.  Standard Library Function : TRUNC
  992.  Standard Library Function : VAL
  993.  Standard Library Function : EXP
  994.  
  995. Related Topics :
  996.  Extended Library
  997.  
  998.  
  999. ******************************************************************************
  1000. *                       Standard Library Function : PI                       *
  1001. ******************************************************************************
  1002.  
  1003. function pi : real;
  1004.  
  1005. The PI function returns the PI value.
  1006.  
  1007.  
  1008. ******************************************************************************
  1009. *                      Standard Library Function : EXP                       *
  1010. ******************************************************************************
  1011.  
  1012. function exp(r : real) : real;
  1013.  
  1014. Returns the exponent of (r).
  1015.  
  1016.  
  1017. ******************************************************************************
  1018. *                      Standard Library Function : SIN                       *
  1019. ******************************************************************************
  1020.  
  1021.  
  1022.  
  1023.  
  1024.                   pasterp, Page #  14   Date 17-5-1994 Tuesday
  1025.                                     -   15 -
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031. function sin(r : real) : real;
  1032.  
  1033. Returns the Sin of (r).
  1034.  
  1035.  
  1036. ******************************************************************************
  1037. *                     Standard Library Function : RANDOM                     *
  1038. ******************************************************************************
  1039.  
  1040. function random(l : longint) : longint;
  1041.  
  1042. Returns a LONGINT in the range 0 .. l .
  1043.  
  1044.  
  1045. ******************************************************************************
  1046. *                      Standard Library Function : COS                       *
  1047. ******************************************************************************
  1048.  
  1049. function cos(r : real) : real;
  1050.  
  1051. Returns the Cos of (r).
  1052.  
  1053.  
  1054. ******************************************************************************
  1055. *                       Standard Library Function : LN                       *
  1056. ******************************************************************************
  1057.  
  1058. function ln(r : real) : real;
  1059.  
  1060. Return the Ln of (r).
  1061.  
  1062.  
  1063. ******************************************************************************
  1064. *                     Standard Library Function : LOG10                      *
  1065. ******************************************************************************
  1066.  
  1067. function log10(r : real) : real;
  1068.  
  1069. Returns the log (base 10) of (r).
  1070.  
  1071.  
  1072. ******************************************************************************
  1073. *                      Standard Library Function : LOG2                      *
  1074. ******************************************************************************
  1075.  
  1076. function log2(r : real) : real;
  1077.  
  1078. Returns the log (base 2) of (r).
  1079.  
  1080.  
  1081. ******************************************************************************
  1082. *                      Standard Library Function : ABS                       *
  1083. ******************************************************************************
  1084.  
  1085.  
  1086.  
  1087.  
  1088.                   pasterp, Page #  15   Date 17-5-1994 Tuesday
  1089.                                     -   16 -
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095. function abs(r : real) : real;
  1096.  
  1097. Returns the absolute value of (r).
  1098.  
  1099.  
  1100. ******************************************************************************
  1101. *                     Standard Library Function : ARCTAN                     *
  1102. ******************************************************************************
  1103.  
  1104. function arctan(r : real) : real;
  1105.  
  1106. Returns the Arctan of (r).
  1107.  
  1108.  
  1109. ******************************************************************************
  1110. *                      Standard Library Function : SQR                       *
  1111. ******************************************************************************
  1112.  
  1113. function sqr(r : real) : real;
  1114.  
  1115. Returns the square of (r).
  1116.  
  1117.  
  1118. ******************************************************************************
  1119. *                      Standard Library Function : SQRT                      *
  1120. ******************************************************************************
  1121.  
  1122. function sqrt(r : real) : real;
  1123.  
  1124. Returns the square root of (r).
  1125.  
  1126.  
  1127. ******************************************************************************
  1128. *                      Standard Library Function : TAN                       *
  1129. ******************************************************************************
  1130.  
  1131. function tan(r : real) : real;
  1132.  
  1133. Returns the Tan of (r).
  1134.  
  1135.  
  1136. ******************************************************************************
  1137. *                     Standard Library Function : COTAN                      *
  1138. ******************************************************************************
  1139.  
  1140. function cotan(r : real) : real;
  1141.  
  1142. Returns the COTAN of (r).
  1143.  
  1144.  
  1145. ******************************************************************************
  1146. *                     Standard Library Function : ARCSIN                     *
  1147. ******************************************************************************
  1148.  
  1149.  
  1150.  
  1151.  
  1152.                   pasterp, Page #  16   Date 17-5-1994 Tuesday
  1153.                                     -   17 -
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159. function arcsin(r : real) : real;
  1160.  
  1161. Returns the Arcsin of (r).
  1162.  
  1163.  
  1164. ******************************************************************************
  1165. *                     Standard Library Function : ARCCOS                     *
  1166. ******************************************************************************
  1167.  
  1168. function arccos(r : real) : real;
  1169.  
  1170. Returns the Arccos of (r).
  1171.  
  1172.  
  1173. ******************************************************************************
  1174. *                      Standard Library Function : CHR                       *
  1175. ******************************************************************************
  1176.  
  1177. function chr(b : byte) : char;
  1178.  
  1179. Returns the CHAR representation of (b).
  1180.  
  1181.  
  1182. ******************************************************************************
  1183. *                      Standard Library Function : ORD                       *
  1184. ******************************************************************************
  1185.  
  1186. function ord(c : char) : byte;
  1187.  
  1188. Returns the ordinal number (representation) of (c).
  1189.  
  1190.  
  1191. ******************************************************************************
  1192. *                     Standard Library Function : TRUNC                      *
  1193. ******************************************************************************
  1194.  
  1195. function trunc(r : real) : longint;
  1196.  
  1197. Returns (r), truncated.
  1198.  
  1199.  
  1200. ******************************************************************************
  1201. *                     Standard Library Function : ROUND                      *
  1202. ******************************************************************************
  1203.  
  1204. function round(r : real) : longint;
  1205.  
  1206. Returns (r), rounded.
  1207.  
  1208.  
  1209. ******************************************************************************
  1210. *                      Standard Library Function : COPY                      *
  1211. ******************************************************************************
  1212.  
  1213.  
  1214.  
  1215.  
  1216.                   pasterp, Page #  17   Date 17-5-1994 Tuesday
  1217.                                     -   18 -
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223. function copy(s : string, i : byte, l : byte) : string;
  1224.  
  1225. Returns the substring of (s), that start and index (i), for (l) bytes.
  1226.  
  1227.  
  1228. ******************************************************************************
  1229. *                     Standard Library Function : LENGTH                     *
  1230. ******************************************************************************
  1231.  
  1232. function length(s : string) : byte;
  1233.  
  1234. Returns the length of (s).
  1235.  
  1236.  
  1237. ******************************************************************************
  1238. *                     Standard Library Function : INSERT                     *
  1239. ******************************************************************************
  1240.  
  1241. function insert(s : string, var d : string, i : index);
  1242.  
  1243. Inserts (s) into (d), after position (i).
  1244.  
  1245.  
  1246. ******************************************************************************
  1247. *                     Standard Library Function : DELETE                     *
  1248. ******************************************************************************
  1249.  
  1250. procedure delete(var s : string, i : byte, c : byte) : char;
  1251.  
  1252. Delete (c) bytes from position (i) of (s).
  1253.  
  1254.  
  1255. ******************************************************************************
  1256. *                      Standard Library Function : POS                       *
  1257. ******************************************************************************
  1258.  
  1259. function pos(s : string, d : string) : integer;
  1260.  
  1261. Returns the position of (d) in (s), 0 if not found.
  1262.  
  1263.  
  1264. ******************************************************************************
  1265. *                      Standard Library Function : VAL                       *
  1266. ******************************************************************************
  1267.  
  1268. function val(s : string, var r : real) : integer;
  1269.  
  1270. Returns the value of (s), in (r). If the function returns 0, the conversion was
  1271. successful, otherwise it points to the index in (s), where the conversion failed.
  1272.  
  1273.  
  1274. ******************************************************************************
  1275. *                      Standard Library Function : STR                       *
  1276. ******************************************************************************
  1277.  
  1278.  
  1279.  
  1280.                   pasterp, Page #  18   Date 17-5-1994 Tuesday
  1281.                                     -   19 -
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288. procedure str(r : real, var s : string);
  1289.  
  1290. Returns the string representation of (r) in (s).
  1291.  
  1292.  
  1293. ******************************************************************************
  1294. *                     Standard Library Function : ASSIGN                     *
  1295. ******************************************************************************
  1296.  
  1297. procedure assign(t : text, s : string);
  1298.  
  1299. Associates the text file (t), with the file name specified in (s).
  1300.  
  1301. Please note that PASTERP supports automatic assignment of a file name to a
  1302. text variable during the variables definition.
  1303.  
  1304. The following two code fragments are equivalent :
  1305.  
  1306. Figure A :
  1307.  
  1308. var
  1309.         t : text;
  1310. endvar
  1311.         assign(t, "myfile.txt");      
  1312.  
  1313.  
  1314. Figure B :
  1315.  
  1316. var
  1317.         t : text = "myfile.txt";
  1318. endvar
  1319.  
  1320.  
  1321. ******************************************************************************
  1322. *                     Standard Library Function : RESET                      *
  1323. ******************************************************************************
  1324.  
  1325. function reset(t : text) : byte;
  1326.  
  1327. Resets (t) for input, and returns an error code. If the function returns 0, the 
  1328. reset operation was successful
  1329.  
  1330.  
  1331. ******************************************************************************
  1332. *                     Standard Library Function : CLOSE                      *
  1333. ******************************************************************************
  1334.  
  1335. function close(t : text) : byte;
  1336.  
  1337. Closes the text file (t), and returns an error code. If the function returns 0, 
  1338. no error occurred.
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.                   pasterp, Page #  19   Date 17-5-1994 Tuesday
  1345.                                     -   20 -
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351. ******************************************************************************
  1352. *                     Standard Library Function : APPEND                     *
  1353. ******************************************************************************
  1354.  
  1355. function append(t : text) : byte;
  1356.  
  1357. Opens (t) for output, from the end of the file. Returns an error code. If the 
  1358. function returns 0, no error occurred.
  1359.  
  1360.  
  1361. ******************************************************************************
  1362. *                    Standard Library Function : REWRITE                     *
  1363. ******************************************************************************
  1364.  
  1365. function rewrite(t : text) : byte;
  1366.  
  1367. Opens (t) for output, rewriting over any previous file with the same name.
  1368. The function returns an error code, or 0 if no error occurred.
  1369.  
  1370.  
  1371. ******************************************************************************
  1372. *                      Standard Library Function : EOF                       *
  1373. ******************************************************************************
  1374.  
  1375. function eof(t : text) : Boolean;
  1376.  
  1377. Returns TRUE if the file pointer of (t) is at the end of file.
  1378.  
  1379.  
  1380. ******************************************************************************
  1381. *                      Standard Library Function : INC                       *
  1382. ******************************************************************************
  1383.  
  1384. procedure inc(var v[, by : real]);
  1385.  
  1386. Increments the variable (v) that must be of a numeric type. If the optional (by)
  1387. parameter is specified, (v) is incremented using (by). Otherwise, (by) is assumed
  1388. to be 1.
  1389.  
  1390.  
  1391. ******************************************************************************
  1392. *                      Standard Library Function : DEC                       *
  1393. ******************************************************************************
  1394.  
  1395. procedure dec(var v[, by : real]);
  1396.  
  1397. Decrement the variable (v) (must be of a numeric type). If the optional (by)
  1398. parameter is specified, (v) is decremented using (by). Otherwise, (by) is assumed
  1399. to be 1.
  1400.  
  1401.  
  1402. ******************************************************************************
  1403. *                          PASTERP Extended Library                          *
  1404. ******************************************************************************
  1405.  
  1406.  
  1407.  
  1408.                   pasterp, Page #  20   Date 17-5-1994 Tuesday
  1409.                                     -   21 -
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416. Extended library will be supplied in a future version, and will support 
  1417. functions that are more related to the PC environment.
  1418.  
  1419. The following functions and procedures are defined in the extended library :
  1420.  
  1421.  
  1422. Related Topics :
  1423.  Standard Library
  1424.  
  1425.  
  1426. ******************************************************************************
  1427. *                     PASTERP Interface to host language                     *
  1428. ******************************************************************************
  1429.  
  1430. The PASTERP language is designed to be embedded as an extension interpreted
  1431. language to application. The first target for host embedding are Borland
  1432. PASCAL applications. This section describes the PASCAL interface between a
  1433. host application and the PASTERP objects.
  1434.  
  1435. The PASTERP interface is described in the following sections :
  1436.  
  1437.  Overview of PASTERP <-> PASCAL interface
  1438.  Initializing a PASTERP instance
  1439.  Registering Procedures and Functions
  1440.  Extending the PASTERP syntax/system library
  1441.  
  1442.  
  1443. ******************************************************************************
  1444. *                  Overview of PASTERP <-> PASCAL interface                  *
  1445. ******************************************************************************
  1446.  
  1447. The PASTERP extension language is implemented as a hierarchy of PARSER 
  1448. object classes in Borland Pascal with Objects.
  1449.  
  1450. The base object of the hierarchy is called basicParser, because it provides
  1451. that basic operation of the PASTERP language interpreter.
  1452.  
  1453. This object includes the code for scanning the input source files, building the
  1454. internal data representations, and dispatching the code using a recursive
  1455. decent parser.
  1456.  
  1457. The most basic PASTERP enabled applications will initialize a basicParser
  1458. object instance, attach a source file to it, and call it to execute macros 
  1459. at different points of the application's execution.
  1460.  
  1461. The basicParser object class defines the interface used to register new 
  1462. functions and procedures to the run-time version of the parser.
  1463.  
  1464. Future versions of the PASTERP development kit will offer extended parser
  1465. object classes that will offer extended functionality. The extended library
  1466. features that will appear in a future version of PASTERP, will be implemented
  1467. as a descendent parser, that adds these functions. Please note that you can create
  1468. descendent parsers with your application's specific functions with this version
  1469.  
  1470.  
  1471.  
  1472.                   pasterp, Page #  21   Date 17-5-1994 Tuesday
  1473.                                     -   22 -
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479. of the PASTERP development kit.
  1480.  
  1481. Please note that the information presented in this electronic document is partial,
  1482. and that the complete parser object class description is presented with the
  1483. PASTERP Development Kit documentation.
  1484.  
  1485.  
  1486. ******************************************************************************
  1487. *                      Initializing a PASTERP instance                       *
  1488. ******************************************************************************
  1489.  
  1490. The basicParser object class defines the following constructors and procedures
  1491. used for initializing a PASTERP instance.
  1492.  
  1493.       constructor init;
  1494.       constructor initFile(const s : string);
  1495.       procedure loadFile(const s : string);
  1496.  
  1497. The init constructor initializes the basicParser internal data structures and 
  1498. run time tables.
  1499.  
  1500. The initFile constructor calls init, and than calls loadFile.
  1501.  
  1502. The loadFile procedure reads a source PASTERP file to the internal basicParser
  1503. source structures, and build the preliminary procedure call structure.
  1504.  
  1505.  
  1506. ******************************************************************************
  1507. *                    Registering Procedures and Functions                    *
  1508. ******************************************************************************
  1509.  
  1510. The basicParser object class defines the following methods that are used to
  1511. register functions that are provided by the host application :
  1512.  
  1513.  
  1514.       procedure registerProc(n : strID; returnType : word;
  1515.                              procAddress : procedureVar);
  1516.       procedure registerProcParm(n : strID; parmType : word;
  1517.                                  byReference : Boolean);
  1518.  
  1519. The registerProc method receives a name for the procedure (n), the 
  1520. return type of the procedure/function (returnType), and the address of 
  1521. the procedure that handles the function.
  1522.  
  1523. The registerProcParm is used to define the parameters that the host application
  1524. procedure needs to receive from the calling PASTERP procedure. The procedure
  1525. name (n), the type of the parameter (parmType) and whether the parameter
  1526. is passed by value or reference (byRefence) should be specified.
  1527.  
  1528. If multiple parameters can be passed to the host application procedure, calls
  1529. to the registerProcParm must be created in the order of the parameters that 
  1530. should be passed to the procedure.
  1531.  
  1532. example :
  1533.  
  1534.  
  1535.  
  1536.                   pasterp, Page #  22   Date 17-5-1994 Tuesday
  1537.                                     -   23 -
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544. Let's assume that we are writing yet another text editor, and we want the 
  1545. extension language, implemented using PASTERP, to be able and call a 
  1546. special goto-position procedure, and a function that returns the current
  1547. line the cursor is on.
  1548.  
  1549. We will define the GOTOPOS procedure of our application to PASTERP using :
  1550.  
  1551.         myParser.registerProc('gotopos', ftVoid, fnGotoPos);
  1552.         myParser.registerProcParm('gotopos', ftLongint, false);
  1553.         myParser.registerProcParm('gotopos', ftLongint, false);
  1554. Here we define a function that returns void called gotopos, the function is
  1555. implemented by an internal procedure in out application, called fnGotoPos
  1556.  
  1557. We define two parameters of type longint to the procedure, and both of them
  1558. are passed by value.
  1559.  
  1560. We will now define the CURRENTLINE function of our application :
  1561.  
  1562.         myParser.registerProc('currentline', ftLongint, fnCurrentLine);
  1563.  
  1564. Here we defined a function called currentline that returns a longint value,
  1565. and is implemented by a PASCAL procedure called fnCurrentLine.
  1566.  
  1567. In our PASCAL code, that implements these functions, we use a pointer
  1568. to an array of pointers called funcParm to access the parameters passed to
  1569. use by the PASTERP code, and return the result of the PASCAL function
  1570. (if any), in a global variable called funcReusltTYPE, where TYPE is the
  1571. type the function returns.
  1572.  
  1573. Example :
  1574.  
  1575. procedure fnGotoPos;
  1576. begin
  1577.         myEditor.gotoPos(longPtr(funcParm^[1])^, longPtr(funcParm^[2])^);
  1578.         funcSuccess := true;
  1579. end; { fnGotoPos }
  1580.  
  1581. In this procedure we called our application's myEditor object's gotoPos
  1582. method, with two longint parameters that were passed through funcParm. 
  1583. Notice that a type cast to the appropriate parameter type was needed.
  1584.  
  1585. The funcSuccess global variable is used to inform the PASTERP interpreter
  1586. that the function was executed with no errors.
  1587.  
  1588. Example :
  1589.  
  1590. procedure fnCurrentLine;
  1591. begin
  1592.         funcResultLong := myEditor.getCurrentLine;
  1593.         funcSuccess := true;
  1594. end; { fnCurrentLine }
  1595.  
  1596. In here we return a result to funcResultLong, using a call to our editor's 
  1597.  
  1598.  
  1599.  
  1600.                   pasterp, Page #  23   Date 17-5-1994 Tuesday
  1601.                                     -   24 -
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607. object getCurrentLine method.
  1608.  
  1609. After we defined these functions as new functions for the PASTERP interpreter,
  1610. our users can write the following code in the PASTERP language that will do 
  1611. something :
  1612.  
  1613. procedure whatever
  1614.         if (currentLine < 30)
  1615.                 gotoPos(30, 1)
  1616.         endif
  1617. endproc
  1618.  
  1619. Please note that this topic presented just the basics of adding functions and 
  1620. procedures to the PASTERP run-time, a complete documentation is available
  1621. with the PASTERP development kit documentation.
  1622.  
  1623.  
  1624. ******************************************************************************
  1625. *                Extending the PASTERP syntax/system library                 *
  1626. ******************************************************************************
  1627.  
  1628. There are three ways to extend the PASTERP syntax: modification of the source 
  1629. code, overriding the basicParser parse method and registering system 
  1630. procedures.
  1631.  
  1632. Modification of the PASTERP source code is available to people that purchase
  1633. the PASTERP source code.
  1634.  
  1635. Overriding the parse method of the basicParser is a technique that requires
  1636. a description of the recursive decent implementation of the basicParser
  1637. object class, and the way the parser maintains scope parameters. This 
  1638. discussion is beyond the scope of this on-line document, but it appears
  1639. in the PASTERP development kit documentation.
  1640.  
  1641. System Procedures are special procedures that are implemented as methods
  1642. of a parser object that is a descendent of the basicParser object class.
  1643.  
  1644. The methods should registered as system procedures, and assigned a unique
  1645. procedure id, that will be used during the dispatching of the methods.
  1646.  
  1647. The power that a system procedure has that a standard registered procedure lacks,
  1648. is that the system procedure can use all the basicParser scanning methods,
  1649. to implement lookahead if needed, and to perform special functions 
  1650. according to the type of the arguments.
  1651.  
  1652. In the basicParser object class, system library procedures such as inc, and
  1653. reset are implemented as system procedures.
  1654.  
  1655. The inc procedure was implemented as a system procedure, because the PASTERP
  1656. syntax allows inc to be either 
  1657.  
  1658. inc(myVar)
  1659.  
  1660. or
  1661.  
  1662.  
  1663.  
  1664.                   pasterp, Page #  24   Date 17-5-1994 Tuesday
  1665.                                     -   25 -
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672. inc(myVar, 12)
  1673.  
  1674. Inc uses the basicParser peekToken, getToken and getNumExpr methods to
  1675. determine whether myVar should be incremented by 1 (syntax 1), or by 12
  1676. (syntax 2).
  1677.  
  1678. The reset function was implemented as a system procedure, because in a future
  1679. version of PASTERP that will support both TEXT and Binary files (and not just
  1680. TEXT files as of today), reset(f) will be able to perform different functions
  1681. according to the type of f, after accessing basicParser's internal vars
  1682. table.
  1683.  
  1684. The complete discussion of extending PASTERP by registering and writing
  1685. system procedures is included with the PASTERP development kit.
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.                   pasterp, Page #  25   Date 17-5-1994 Tuesday
  1729.                                  - INDEX-   1 -
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735. ABS : 
  1736.  Standard Library Function : ABS ......................................     15
  1737. APPEND : 
  1738.  Standard Library Function : APPEND ...................................     19
  1739. ARCCOS : 
  1740.  Standard Library Function : ARCCOS ...................................     17
  1741. ARCSIN : 
  1742.  Standard Library Function : ARCSIN ...................................     16
  1743. ARCTAN : 
  1744.  Standard Library Function : ARCTAN ...................................     16
  1745. ASSIGN : 
  1746.  Assignment Statement .................................................      4
  1747.  Standard Library Function : ASSIGN ...................................     19
  1748. BOOLEAN : 
  1749.  Logical (Boolean) Expressions ........................................     12
  1750. CALL : 
  1751.  Procedure Call Statement .............................................      8
  1752. CHR : 
  1753.  Standard Library Function : CHR ......................................     17
  1754. CLOSE : 
  1755.  Standard Library Function : CLOSE ....................................     19
  1756. CONDITIONAL : 
  1757.  IF Statement .........................................................      4
  1758.  WHILE Statement ......................................................      5
  1759. CONTINUE : 
  1760.  CONTINUE Statement ...................................................     10
  1761. COPY : 
  1762.  Standard Library Function : COPY .....................................     17
  1763. COS : 
  1764.  Standard Library Function : COS ......................................     15
  1765. COTAN : 
  1766.  Standard Library Function : COTAN ....................................     16
  1767. DEC : 
  1768.  Standard Library Function : DEC ......................................     20
  1769. DELETE : 
  1770.  Standard Library Function : DELETE ...................................     18
  1771. EOF : 
  1772.  Standard Library Function : EOF ......................................     20
  1773. EXP : 
  1774.  Standard Library Function : EXP ......................................     14
  1775. EXPRESSIONS : 
  1776.  Logical (Boolean) Expressions ........................................     12
  1777.  Numeric Expressions ..................................................     11
  1778.  String Expressions ...................................................     12
  1779. EXTENDED : 
  1780.  PASTERP Extended Library .............................................     20
  1781. EXTENDING : 
  1782.  Extending the PASTERP syntax/system library ..........................     24
  1783. FOR : 
  1784.  FOR Statement ........................................................      5
  1785. FUNCTION : 
  1786.  Procedure/Function Definition Statement ..............................      9
  1787.  RETURN Statement .....................................................      8
  1788. GLOBAL : 
  1789.  
  1790.  
  1791.  
  1792.                                  - INDEX-   1 -
  1793.                                  - INDEX-   2 -
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  GLOBAL Statement .....................................................      2
  1800. IF : 
  1801.  IF Statement .........................................................      4
  1802. INC : 
  1803.  Standard Library Function : INC ......................................     20
  1804. INITIALIZE : 
  1805.  Initializing a PASTERP instance ......................................     22
  1806. INPUT : 
  1807.  READLN Statement .....................................................      7
  1808.  READ Statement .......................................................      7
  1809. INSERT : 
  1810.  Standard Library Function : INSERT ...................................     18
  1811. INTERFACE : 
  1812.  Overview of PASTERP <-> PASCAL interface .............................     21
  1813.  Extending the PASTERP syntax/system library ..........................     24
  1814.  PASTERP Interface to host language ...................................     21
  1815.  Initializing a PASTERP instance ......................................     22
  1816.  Registering Procedures and Functions .................................     22
  1817. LANGUAGE : 
  1818.  EXPRESSIONS ..........................................................     11
  1819.  PASTERP Language  ....................................................      1
  1820.  STATEMENTS ...........................................................      1
  1821.  VARIABLES ............................................................     10
  1822. LENGTH : 
  1823.  Standard Library Function : LENGTH ...................................     18
  1824. LIBRARY : 
  1825.  PASTERP Extended Library .............................................     20
  1826.  PASTERP Library ......................................................     13
  1827.  PASTERP Standard Library .............................................     13
  1828.  Standard Library Function : ABS ......................................     15
  1829.  Standard Library Function : APPEND ...................................     19
  1830.  Standard Library Function : ARCCOS ...................................     17
  1831.  Standard Library Function : ARCSIN ...................................     16
  1832.  Standard Library Function : ARCTAN ...................................     16
  1833.  Standard Library Function : ASSIGN ...................................     19
  1834.  Standard Library Function : CHR ......................................     17
  1835.  Standard Library Function : CLOSE ....................................     19
  1836.  Standard Library Function : COPY .....................................     17
  1837.  Standard Library Function : COS ......................................     15
  1838.  Standard Library Function : COTAN ....................................     16
  1839.  Standard Library Function : DEC ......................................     20
  1840.  Standard Library Function : DELETE ...................................     18
  1841.  Standard Library Function : EOF ......................................     20
  1842.  Standard Library Function : INC ......................................     20
  1843.  Standard Library Function : INSERT ...................................     18
  1844.  Standard Library Function : LENGTH ...................................     18
  1845.  Standard Library Function : LN .......................................     15
  1846.  Standard Library Function : LOG10 ....................................     15
  1847.  Standard Library Function : LOG2 .....................................     15
  1848.  Standard Library Function : ORD ......................................     17
  1849.  Standard Library Function : PI .......................................     14
  1850.  Standard Library Function : POS ......................................     18
  1851.  Standard Library Function : RANDOM ...................................     15
  1852.  Standard Library Function : RESET ....................................     19
  1853.  
  1854.  
  1855.  
  1856.                                  - INDEX-   2 -
  1857.                                  - INDEX-   3 -
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  Standard Library Function : REWRITE ..................................     20
  1864.  Standard Library Function : ROUND ....................................     17
  1865.  Standard Library Function : SIN ......................................     14
  1866.  Standard Library Function : SQR ......................................     16
  1867.  Standard Library Function : SQRT .....................................     16
  1868.  Standard Library Function : STR ......................................     18
  1869.  Standard Library Function : TAN ......................................     16
  1870.  Standard Library Function : TRUNC ....................................     17
  1871.  Standard Library Function : VAL ......................................     18
  1872.  Standard Library Function : EXP ......................................     14
  1873. LN : 
  1874.  Standard Library Function : LN .......................................     15
  1875. LOCAL : 
  1876.  LOCAL Statement ......................................................      2
  1877. LOG10 : 
  1878.  Standard Library Function : LOG10 ....................................     15
  1879. LOG2 : 
  1880.  Standard Library Function : LOG2 .....................................     15
  1881. LOGICAL : 
  1882.  Logical (Boolean) Expressions ........................................     12
  1883. LOOP : 
  1884.  CONTINUE Statement ...................................................     10
  1885.  FOR Statement ........................................................      5
  1886.  REPEAT Statement .....................................................      6
  1887. NUMERIC : 
  1888.  Numeric Expressions ..................................................     11
  1889. ORD : 
  1890.  Standard Library Function : ORD ......................................     17
  1891. OVERVIEW : 
  1892.  Overview of PASTERP <-> PASCAL interface .............................     21
  1893.  OVERVIEW .............................................................      1
  1894. PASTERP : 
  1895.  OVERVIEW .............................................................      1
  1896. PI : 
  1897.  Standard Library Function : PI .......................................     14
  1898. POS : 
  1899.  Standard Library Function : POS ......................................     18
  1900. PROCEDURE : 
  1901.  Procedure Call Statement .............................................      8
  1902.  Procedure/Function Definition Statement ..............................      9
  1903.  RETURN Statement .....................................................      8
  1904. RANDOM : 
  1905.  Standard Library Function : RANDOM ...................................     15
  1906. READ : 
  1907.  READ Statement .......................................................      7
  1908. READLN : 
  1909.  READLN Statement .....................................................      7
  1910. REGISTER : 
  1911.  Registering Procedures and Functions .................................     22
  1912. REPEAT : 
  1913.  REPEAT Statement .....................................................      6
  1914. RESET : 
  1915.  Standard Library Function : RESET ....................................     19
  1916. RETURN : 
  1917.  
  1918.  
  1919.  
  1920.                                  - INDEX-   3 -
  1921.                                  - INDEX-   4 -
  1922.  
  1923.  
  1924.  
  1925.  
  1926.  
  1927.  RETURN Statement .....................................................      8
  1928. REWRITE : 
  1929.  Standard Library Function : REWRITE ..................................     20
  1930. ROUND : 
  1931.  Standard Library Function : ROUND ....................................     17
  1932. SIN : 
  1933.  Standard Library Function : SIN ......................................     14
  1934. SQR : 
  1935.  Standard Library Function : SQR ......................................     16
  1936. SQRT : 
  1937.  Standard Library Function : SQRT .....................................     16
  1938. STANDARD : 
  1939.  PASTERP Standard Library .............................................     13
  1940.  Standard Library Function : ABS ......................................     15
  1941.  Standard Library Function : APPEND ...................................     19
  1942.  Standard Library Function : ARCCOS ...................................     17
  1943.  Standard Library Function : ARCSIN ...................................     16
  1944.  Standard Library Function : ARCTAN ...................................     16
  1945.  Standard Library Function : ASSIGN ...................................     19
  1946.  Standard Library Function : CHR ......................................     17
  1947.  Standard Library Function : CLOSE ....................................     19
  1948.  Standard Library Function : COPY .....................................     17
  1949.  Standard Library Function : COS ......................................     15
  1950.  Standard Library Function : COTAN ....................................     16
  1951.  Standard Library Function : DEC ......................................     20
  1952.  Standard Library Function : DELETE ...................................     18
  1953.  Standard Library Function : EOF ......................................     20
  1954.  Standard Library Function : INC ......................................     20
  1955.  Standard Library Function : INSERT ...................................     18
  1956.  Standard Library Function : LENGTH ...................................     18
  1957.  Standard Library Function : LN .......................................     15
  1958.  Standard Library Function : LOG10 ....................................     15
  1959.  Standard Library Function : LOG2 .....................................     15
  1960.  Standard Library Function : ORD ......................................     17
  1961.  Standard Library Function : PI .......................................     14
  1962.  Standard Library Function : POS ......................................     18
  1963.  Standard Library Function : RANDOM ...................................     15
  1964.  Standard Library Function : RESET ....................................     19
  1965.  Standard Library Function : REWRITE ..................................     20
  1966.  Standard Library Function : ROUND ....................................     17
  1967.  Standard Library Function : SIN ......................................     14
  1968.  Standard Library Function : SQR ......................................     16
  1969.  Standard Library Function : SQRT .....................................     16
  1970.  Standard Library Function : STR ......................................     18
  1971.  Standard Library Function : TAN ......................................     16
  1972.  Standard Library Function : TRUNC ....................................     17
  1973.  Standard Library Function : VAL ......................................     18
  1974.  Standard Library Function : EXP ......................................     14
  1975. STATEMENT : 
  1976.  Assignment Statement .................................................      4
  1977.  CONTINUE Statement ...................................................     10
  1978.  FOR Statement ........................................................      5
  1979.  GLOBAL Statement .....................................................      2
  1980.  IF Statement .........................................................      4
  1981.  
  1982.  
  1983.  
  1984.                                  - INDEX-   4 -
  1985.                                  - INDEX-   5 -
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991.  LOCAL Statement ......................................................      2
  1992.  Procedure Call Statement .............................................      8
  1993.  Procedure/Function Definition Statement ..............................      9
  1994.  READLN Statement .....................................................      7
  1995.  READ Statement .......................................................      7
  1996.  REPEAT Statement .....................................................      6
  1997.  RETURN Statement .....................................................      8
  1998.  WHILE Statement ......................................................      5
  1999.  WRITELN Statement ....................................................      4
  2000.  WRITE Statement ......................................................      3
  2001. STATEMENTS : 
  2002.  STATEMENTS ...........................................................      1
  2003. STR : 
  2004.  Standard Library Function : STR ......................................     18
  2005. STRING : 
  2006.  String Expressions ...................................................     12
  2007. TAN : 
  2008.  Standard Library Function : TAN ......................................     16
  2009. TRUNC : 
  2010.  Standard Library Function : TRUNC ....................................     17
  2011. VAL : 
  2012.  Standard Library Function : VAL ......................................     18
  2013. VARIABLE : 
  2014.  GLOBAL Statement .....................................................      2
  2015.  LOCAL Statement ......................................................      2
  2016. VARIABLES : 
  2017.  EXPRESSIONS ..........................................................     11
  2018.  Logical (Boolean) Expressions ........................................     12
  2019.  Numeric Expressions ..................................................     11
  2020.  String Expressions ...................................................     12
  2021.  VARIABLES ............................................................     10
  2022. WHILE : 
  2023.  WHILE Statement ......................................................      5
  2024. WRITE : 
  2025.  WRITE Statement ......................................................      3
  2026. WRITELN : 
  2027.  WRITELN Statement ....................................................      4
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.                                  - INDEX-   5 -
  2049.